< previous page page_616 next page >

Page 616
Listing 15.10. continued
   );
INSERT INTO BaseTable VALUES
   ('CUST03',
    'Anchor, Smith, & Hocking',
    '575.25',
    'RETAIL',
    'This is the last comment'
   );
// now make a new table from the old one
SELECT * INTO CopyTable FROM BaseTable;
// select just some of the records
SELECT * INTO RetailTable FROM BaseTable
   WHERE CustType='RETAIL';
// create a new summary table with fancy stuff added
SELECT CustType, SUM(CustBalance) AS Balance INTO SummaryTable
   FROM BaseTable
   GROUP BY CustType;
// show results
SELECT * FROM BaseTable;
SELECT * FROM CopyTable;
SELECT * FROM RetailTable;
SELECT * FROM SummaryTable;
// eof
0616-01.jpg
Figure 15.11.
Using 
GROUP BY and HAVING to summarize data.

 
< previous page page_616 next page >

If you like this book, buy it!